﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ERPStudio;
using System.Data.SqlClient;

namespace Fares
{
    public partial class ArticoleRezumatFrm : FrmRezumat
    {
        public Int32 IDArtsel = -1;
        private String _denumire = String.Empty;
        public String DenumireArticol
        {
            set
            {
                _denumire = value;
            }
        }
        public ArticoleRezumatFrm(ModuleClass mInfo,Int32 idArt)
            : base(mInfo)
        {
            InitializeComponent();
            IDArtsel = idArt;
            workConnString = "ESRPConnectionString";
            ReadOnly = true;
        }


        private void ArticoleRezumatFrm_Load(object sender, EventArgs e)
        {
            SqlConnection conn = DeschideConexiune(workConnString);
            this.valutaTableAdapter.Connection = conn;
            this.valutaTableAdapter.Fill(this.esrpDataSetArticol.Valuta);
            this.articoleTableAdapter.Connection = conn;
            this.departamenteTableAdapter.Connection = conn;
            this.departamenteTableAdapter.Fill(this.esrpDataSetArticol.Departamente);
            this.unitatiMasuraTableAdapter.Connection = conn;
            this.unitatiMasuraTableAdapter.Fill(this.esrpDataSetArticol.UnitatiMasura);
            this.tipCategoriiArticoleTableAdapter.Connection = conn;
            this.tipCategoriiArticoleTableAdapter.Fill(this.esrpDataSetArticol.TipCategoriiArticole);
            this.stocuriTableAdapter.Connection = conn;
            this.stocuriTableAdapter.Fill(this.esrpDataSetArticol.Stocuri);
            if(_denumire!=String.Empty)
                this.articoleTableAdapter.FillByDenumire(this.esrpDataSetArticol.Articole, ModuleInfo.CodUnitate,_denumire);
            else
                this.articoleTableAdapter.Fill(this.esrpDataSetArticol.Articole,ModuleInfo.CodUnitate);
            InchideConexiune(conn);
            if (IDArtsel != -1)
            {
                int pos = articoleBindingSource.Find("IDArticol", IDArtsel);
                if(pos!=-1)
                    articoleBindingSource.Position=pos;
            }
            EnableMainBrowseButton = false;
        }

        private void stocuriDGV_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
           
        }
    }
}
